package com.juku2024.juku.model

import android.os.Parcel
import android.os.Parcelable

class EpisodesResponse() : Parcelable {
    // 视频的类型
    var videoId: Long = 0
    var category: Int = 2
    var url: String? = null
    var title: String? = null
    // 再播放器上方显示的名称
    var videoTitle: String? = null
    // 当前剧集是否选中
    var isPlaying: Boolean = false
    // 当前剧集是否需要解锁
    var isLockVideoAd: Boolean = false
    // 是否正在下载
    var isDownloading: Boolean = false
    // 是否已经下载完成
    var isDownloaded: Boolean = false
    // 当前下载状态
    var status: Int = -1
    // 是否已观看
    var isPlayed = false


    constructor(parcel: Parcel) : this() {
        videoId = parcel.readLong()
        category = parcel.readInt()
        url = parcel.readString()
        title = parcel.readString()
        videoTitle = parcel.readString()
        isPlaying = parcel.readByte() != 0.toByte()
        isLockVideoAd = parcel.readByte() != 0.toByte()
        isPlayed = parcel.readByte() != 0.toByte()
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeLong(videoId)
        parcel.writeInt(category)
        parcel.writeString(url)
        parcel.writeString(title)
        parcel.writeString(videoTitle)
        parcel.writeByte(if (isPlaying) 1 else 0)
        parcel.writeByte(if (isLockVideoAd) 1 else 0)
        parcel.writeByte(if (isPlayed) 1 else 0)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<EpisodesResponse> {
        override fun createFromParcel(parcel: Parcel): EpisodesResponse {
            return EpisodesResponse(parcel)
        }

        override fun newArray(size: Int): Array<EpisodesResponse?> {
            return arrayOfNulls(size)
        }
    }

}